package org.ww.order.web;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.ww.common.constant.RabbitMqConstant;
import org.ww.order.entity.OrderEntity;

import java.util.UUID;

/**
 * @program: gmall
 * @description: hello
 * @author: ww
 * @create: 2024-05-23 11:31
 **/

@Controller
public class HelloController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @ResponseBody
    @GetMapping("/delay/orderTest")
    public String orderTest(){
        OrderEntity entity = new OrderEntity();
        entity.setOrderSn(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend(RabbitMqConstant.ORDER_EVENT_EXCHANGE,RabbitMqConstant.ORDER_CREATE_ORDER_BINDING,entity);
        return "ok";
    }
    @GetMapping("/{page}.html")
    public String pageList(@PathVariable("page") String page){

        return page;
    }

}
